﻿using IDAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class D_UserCloudData : IUserCloudData
    {
        WishDayEntities _e;
        public D_UserCloudData()
            {
            _e = new WishDayEntities();
             }
        public void Add(UserCloudData obj)
        {
            _e.UserCloudData.Add(obj);
            _e.SaveChanges();
        }

        public void Delete(int id)
        {
            var data = _e.UserCloudData.Find(id);
            _e.UserCloudData.Remove(data);
            _e.SaveChanges();

        }

        public UserCloudData FindById(int id)
        {
            return _e.UserCloudData.Find(id);
        }

        public List<UserCloudData> GetAll()
        {
            return _e.UserCloudData.ToList();
        }

        public void Update(int id, UserCloudData obj)
        {
            var data = _e.UserCloudData.Find(id);
            data.UCName = obj.UCName;
            data.UCWish = obj.UCWish;
            data.UCIMG = obj.UCIMG;
            data.UserID = obj.UserID;
            data.TemplateID = obj.TemplateID;
            _e.SaveChanges();
        }
    }
}
